package com.marchsoft.group.manager.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.marchsoft.group.manager.common.utils.SecurityUtils;
import com.marchsoft.group.manager.system.entity.Student;
import com.marchsoft.group.manager.system.mapper.StudentMapper;
import com.marchsoft.group.manager.system.service.IStudentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author ZhangHaoQi
 * @since 2020-12-20
 */
@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements IStudentService {

    @Autowired
    StudentMapper studentMapper;

    /**
     * fetch
     * @Author zhanghaoqi
     * @Description  获取学生信息   超级管理员获取所有的学生  小组管理员只获取本小组的学生信息。
     * @Data 21:32 2021/1/18
     * @param
     * @return java.util.List<com.marchsoft.group.manager.system.entity.Student>
     */
    @Override
    public List<Student> getAllStudents() {
        /**
         *判断是超级管理员登陆还是小组管理员登陆
         * 超级管理员登陆    获取所有学生信息
         * 普通管理员登陆    获取当前学生信息
         */
       boolean role = SecurityUtils.getCurrentUser().getAuthorities().toArray()[0].toString().equals("super_admin");
        if (role) {
            System.out.println("进入");
            List<Student> students = studentMapper.selectList(new QueryWrapper<>());
            System.out.println(students);
            return students;
        }else{

        }
        return null;
    }
}
